<include file="nav:header"/>
<div class="container-fluid">
    <div class="row">
        <include file="Left:left-Common"/>
        <!-- right -->
        <div class="col-md-10 right">
            <div class="page-header" style="margin-right: 15px">
                <h3>{$page_title}</h3>
            </div>
            <div class="col-md-12">
                <div class="btn-group " role="group" aria-label="Large button group">
                    <a href="{:U('Tag/index')}" type="button" class="btn btn-default">بارلىق خەتكۈچلەر</a>
                    <a href="{:U('Tag/add')}" type="button" class="btn btn-default">خەتكۈچ قوشۇش</a>
                </div>
                <!--所有分类-->
                <br><br>
                <table class="table table-bordered">
                    <thead>
                    <tr class="info">
                        <th width="50">ID</th>
                        <th>خەتكۈچ نامى</th>
                        <th width="60">تەرتىبى </th>
                        <th style="text-align: center">ھالىتى</th>
                        <th style="text-align: center">مەشغۇلات</th>
                    </tr>
                    </thead>
                    <tbody>
                    <foreach name="Tags" item="c">
                        <tr class="classifys active">
                            <td>{$c['id']}</td>
                            <td style="font-size: 15px">
                                &nbsp;{$c.tname}
                            </td>
                            <td><input onchange="_sort(this,{$c['id']})" class="form-control" type="text" value="{$c['sort']}" ></td>
                            <td style="text-align: center">
                                <if condition="$c['status'] eq 1">
                                    <span style="margin-top: 6px;display: inline-block;"  onclick="_status(this,0,{$c['id']})"  class="btn btn-success btn-xs kaiguan">ئوچۇق</span>
                                    <else/>
                                    <span style="margin-top: 6px;display: inline-block;" onclick="_status(this,1,{$c['id']})" class="btn btn-danger btn-xs kaiguan">تاقاق</span>
                                </if>
                            </td>
                            <td style="text-align: center">
                                <a  style="margin-top: 6px;display: inline-block;" href="{:U('Tag/edit',array('id'=>$c['id']))}" class="btn btn-success btn-xs ">تەھرىرلەش</a>
                                <a  style="margin-top: 6px;display: inline-block;" href="javascript:del({$c['id']});" class="btn btn-danger btn-xs">ئۆچۈرۈش</a>
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    //分类排序
    function _sort(obj,id) {
        var val=$(obj).val();
        $.ajax({
            type:"post",
            url:"{:U('Tag/sortfen')}",
            dataType:"json",
            data:{"sort":val,"id":id},
            success:function (phpdata) {
                if(phpdata.status==1){
                    layer.alert(phpdata.message, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 6,
                        skin: 'layer-ext-moon',
                        time:800
                    });
                    window.location=location;
                }else{
                    layer.alert(phpdata.message, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 5,
                        skin: 'layer-ext-moon',
                        time:1000
                    });
                }
            }
        })
    }
    //删除分类
    function del(id) {
            layer.confirm('بۇ ئۇچۇرنى راستىنلا ئۆچۈرەمسىز ؟', {
                btn: ['ھەئە','ياق'] //按钮
            },function () {
                $.ajax({
                    type:"post",
                    url:"{:U('Tag/del')}",
                    dataType:"json",
                    data:{"id":id},
                    success:function (phpdata) {
                        if(phpdata.status==1){
                            layer.alert(phpdata.message, {
                                title:"سېستىما ئەسكەرتىشى",
                                btn:"بىلدىم",
                                icon: 6,
                                skin: 'layer-ext-moon',
                                time:800
                            });
                            window.location=location;
                        }else{
                            layer.alert(phpdata.message, {
                                title:"سېستىما ئەسكەرتىشى",
                                btn:"بىلدىم",
                                icon: 5,
                                skin: 'layer-ext-moon',
                                time:1000
                            });
                        }
                    }
                })
            });
        }
    //分类状态
    function _status(obj,status,id) {
        if(status=='0'){
            $(obj).removeClass("btn-success");
            $(obj).addClass("btn-danger");
            $(obj).text("تاقاق")
        }else {
            $(obj).removeClass("btn-danger");
            $(obj).addClass("btn-success");
            $(obj).text("ئوچۇق")
        }
        $.ajax({
            type:"post",
            url:"{:U('Tag/sortStatus')}",
            dataType:"json",
            data:{"id":id,"status":status},
            success:function (phpdata) {
                if(phpdata.status==1){
                    layer.alert(phpdata.content, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 6,
                        skin: 'layer-ext-moon',
                        time:400
                    });
                    window.location=location;
                }else{
                    layer.alert(phpdata.content, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 5,
                        skin: 'layer-ext-moon',
                        time:1000
                    });
                }
            }
        })
    }
    $(function () {
        $('.classifys').hover(function () {
            $(this).addClass('info');
        },function () {
            $(".classifys").removeClass('info');
        })
    })
</script>
<include file="nav:footer"/>